package com.ruoyi.project.module.api.service;

import com.ruoyi.project.system.dict.domain.DictData;
import com.ruoyi.project.system.dict.service.IDictDataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class SearchParamService {

    @Autowired
    private IDictDataService dictDataService;

    public Map<String, Object> getSearchParams(){
        Map<String, Object> result = new HashMap<>();
        DictData dictData = new DictData();

        // 行业
        List<Map<String, Object>> industryParamList = new ArrayList<>();
        dictData.setDictType("app_report_industry");
        List<DictData> dictDataList = dictDataService.selectDictDataList(dictData);
        for(DictData data:dictDataList){
            Map<String, Object> param = new HashMap<>();
            param.put(data.getDictLabel(),data.getDictValue());
            industryParamList.add(param);
        }
        result.put("industry",industryParamList);

        // 类型
        List<Map<String, Object>> typeParamList = new ArrayList<>();
        dictData.setDictType("app_report_type");
        dictDataList = dictDataService.selectDictDataList(dictData);
        for(DictData data:dictDataList){
            Map<String, Object> param = new HashMap<>();
            param.put(data.getDictLabel(),data.getDictValue());
            typeParamList.add(param);
        }
        result.put("type",typeParamList);

        return result;
    }

}
